<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <link rel="icon" href="../assets/favicon.ico">
    <link rel="stylesheet" href="../styles/index.scss">
    <title>Yank Note</title>
    <script>
      // 设置初始主题
      window.document.documentElement.setAttribute('app-theme', JSON.parse(localStorage['app.theme'] || '"system"'))
    </script>
    <script type="module" src="./index.ts"></script>
  </head>
  <body>
    <script>
      window.nodeRequire = window.require
      window.nodeProcess = window.process
      window.nodeModule = window.module
      window.require = undefined
      window.process = undefined
      window.module = undefined

      const params = new URLSearchParams(location.hash.replace('#', '?') || location.search)

      const title = params.get('title')
      if (title) {
        document.title = title
      }

      if (params.get('with-global-style') === 'false') {
        Array.prototype.forEach.call(document.styleSheets, (item) => {
          item.disabled = true
        })
      } else {
        const head = document.getElementsByTagName('head')[0]
        const cssLink = document.createElement('link')
        cssLink.id = 'custom-css'
        cssLink.rel = 'stylesheet'
        cssLink.type = 'text/css'
        cssLink.href = '/custom-css'

        head.appendChild(cssLink)
      }

      if (params.get('debug') === 'false') {
        console.warn = () => 0
        console.log = () => 0
        console.info = () => 0
        console.dir = () => 0
      }

      document.write(params.get('html') || '')
    </script>
  </body>
</html>
